From 1e62891febfe2306551876c52719f396e343e93b Mon Sep 17 00:00:00 2001
From: Isarhamster
+- New Feature: Clear Nags from keyboard with *Del
- New Feature: Create Index File thus accelerating re-loading of large PGN enormously
- New Feature: Searching of ranges, e.g. ELO "2000-2300"
- New Feature: Automatic classification with ECO of unclassified / new games
diff --git a/data/help/about1.html b/data/help/about1.html
index 2f2b9be0..a5367a2f 100644
--- a/data/help/about1.html
+++ b/data/help/about1.html
@@ -99,7 +99,11 @@ Entering moves with the keyboard
typing “e4” in the starting position is fine, whereas a subsequent “e2” could
either be Be2, Ne2, Ke2, Qe2 — or f1e2…
By pressing [Enter] you can force ChessX to accept an entry or discard it, if ChessX cannot make anything reasonable of your entry.
+ChessX will recognize nags like '!' or '+-', a special nag is 'N' (Novelty) which needs to be entered as 'NN'.
+Pressing [ESC] clears the current nag text, [DEL] clears all nags from the current move. +By pressing [Enter] you can force ChessX to accept an entry.
+In this case, ChessX will first try to detect Nags or Moves inside the entered text. Then it will consider special annotations: e.g. '+1:00:00' will enter a remaining +time annotation, '-0:01:00' will result in a elapsed move time annotation. All other texts will replace the current comment.
You can enter castling moves with 00, 0-0, 0k, O-O or 000, 0-0-0, 0q, O-O-O respectively. ‘--’ will generate a null move.
Move annotations can be done by activating the context menu in the games text browser or by simply pressing the corresponding key sequence, diff --git a/src/database/gamex.cpp b/src/database/gamex.cpp index 2550e3fa..7baca99d 100644 --- a/src/database/gamex.cpp +++ b/src/database/gamex.cpp @@ -1157,7 +1157,7 @@ QString GameX::arrowAnnotation(MoveId moveId) const return s; } -QString GameX::specAnnotation(const QRegularExpression &r, MoveId moveId) const +QString GameX::specAnnotation(const QRegularExpression &r, MoveId moveId, QString* found) const { MoveId node = m_moves.makeNodeIndex(moveId); if(node == NO_MOVE) @@ -1176,6 +1176,7 @@ QString GameX::specAnnotation(const QRegularExpression &r, MoveId moveId) const if(pos >= 0) { + if (found) *found = match.captured(1); return match.captured(2); } @@ -1193,9 +1194,10 @@ QString GameX::timeAnnotation(MoveId moveId, Position position) const } else return ""; } - + QString found; QString s = specAnnotation(TimeAnnotation().filter(), moveId); s = s.trimmed(); + if (found == "emt" || found == "egt") s.prepend("-"); // Indicate elapsed times with a '-' return s; } diff --git a/src/database/gamex.h b/src/database/gamex.h index 051a4c50..0f5b2bec 100644 --- a/src/database/gamex.h +++ b/src/database/gamex.h @@ -128,7 +128,7 @@ public : /** @return arrowAnnotation at move at node @p moveId. */ QString arrowAnnotation(MoveId moveId = CURRENT_MOVE) const; /** @return annotation at move at node @p moveId. */ - QString specAnnotation(const QRegularExpression &r, MoveId moveId = CURRENT_MOVE) const; + QString specAnnotation(const QRegularExpression &r, MoveId moveId = CURRENT_MOVE, QString *found=0) const; /** @return time annotation (either egt or clock) at move at node @p moveId. */ QString timeAnnotation(MoveId moveId = CURRENT_MOVE, Position position = AfterMove) const; void setTimeAnnotation(QString annotation, MoveId moveId = CURRENT_MOVE); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 54511441..20c62b9f 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -730,20 +730,44 @@ void MainWindow::evaluateSanNag(QKeyEvent *e) Move m = game().move(); m_ficsConsole->SendMove(m.toAlgebraic()); } + m_nagText.clear(); + return; } - if (m_nagText.startsWith("T")) + if ((m_nagText.length()>=2) && + (m_nagText.startsWith("+") || m_nagText.startsWith("-"))) { // ChessX-Special - annotate a time comment + // + is remaining time, - is elapsed move time + // +/-0:30 is converted to 0:30:00 + // +/-3 is converted into 0:03:00 + // 3 seconds should be entered +/-0:00:03 + char mode = m_nagText[0].toLatin1(); m_nagText.remove(0,1); - if (m_nagText.count(":")==1) m_nagText.append(":00"); + if (m_nagText.count(":")==0) + { + if (m_nagText.length()==1) m_nagText.prepend("0"); + m_nagText.prepend("0:"); + } + if (m_nagText.count(":")==1) + { + m_nagText.append(":00"); + } if (m_nagText.count(":")==2) { QTime t = QTime::fromString(m_nagText, "H:mm:ss"); QString ts = t.toString("H:mm:ss"); - QString annot = ClockAnnotation(ts).asAnnotation(); + QString annot = mode == '+' ? ClockAnnotation(ts).asAnnotation() : ElapsedMoveTimeAnnotation(ts).asAnnotation(); game().setTimeAnnotation(annot); } + m_nagText.clear(); + return; + } + + if (!m_nagText.isEmpty()) + { + game().setAnnotation(m_nagText); // Everything else is added as comment } + m_nagText.clear(); // Not a move and not a nag return; } @@ -768,7 +792,7 @@ void MainWindow::evaluateSanNag(QKeyEvent *e) return; } - if (m_nagText == "n") + if (m_nagText == "NN") { m_nagText = "N"; }