Skip to content

Commit

Permalink
New feature: Enter comments and special annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Isarhamster committed Nov 15, 2024
1 parent 71bb954 commit 1e62891
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 9 deletions.
6 changes: 5 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## September 2024: Version 1.6.4

- Bugfix: Qt6 will not serialize Engine options

## July 2024: Version 1.6.2

- Bugfix:#333 Accented letters in annotations in UTF8
Expand Down Expand Up @@ -535,7 +539,7 @@
- New feature: Toggle UTF8 flag in database list
- New feature: Open compressed archives (from HTTP or local file)
- New feature: Open a database from a URL (HTTP)
- New Feature: Clear Nags from keyboard with <Del>
- 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
Expand Down
6 changes: 5 additions & 1 deletion data/help/about1.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ <h3><a name="Enter"></a>Entering moves with the keyboard</h3>
typing &ldquo;e4&rdquo; in the starting position is fine, whereas a subsequent &ldquo;e2&rdquo; could
either be Be2, Ne2, Ke2, Qe2 &mdash; or f1e2&hellip;
</p>
<p>By pressing [Enter] you can force ChessX to accept an entry or discard it, if ChessX cannot make anything reasonable of your entry.</p>
<p>ChessX will recognize nags like '!' or '+-', a special nag is 'N' (Novelty) which needs to be entered as 'NN'.</p>
<p>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.</p>
<p>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.</p>
<p>You can enter castling moves with 00, 0-0, 0k, O-O or 000, 0-0-0, 0q, O-O-O respectively. &lsquo;--&rsquo; will generate a null move.</p>
<h3><a name="Annotate"></a>Annotating moves</h3>
<p>Move annotations can be done by activating the context menu in the games text browser or by simply pressing the corresponding key sequence,
Expand Down
6 changes: 4 additions & 2 deletions src/database/gamex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/database/gamex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
32 changes: 28 additions & 4 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -768,7 +792,7 @@ void MainWindow::evaluateSanNag(QKeyEvent *e)
return;
}

if (m_nagText == "n")
if (m_nagText == "NN")
{
m_nagText = "N";
}
Expand Down

0 comments on commit 1e62891

Please sign in to comment.